package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ContaxxYuhui;
import com.ruoyi.system.service.IContaxxYuhuiService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 誉辉陶瓷Controller
 *
 * @author Yanghc
 * @date 2024-09-02
 */
@Controller
@RequestMapping("/system/yuhui")
public class ContaxxYuhuiController extends BaseController
{
    private String prefix = "system/yuhui";

    @Autowired
    private IContaxxYuhuiService contaxxYuhuiService;

    @RequiresPermissions("system:yuhui:view")
    @GetMapping()
    public String yuhui()
    {
        return prefix + "/yuhui";
    }

    /**
     * 查询誉辉陶瓷列表
     */
    @RequiresPermissions("system:yuhui:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ContaxxYuhui contaxxYuhui)
    {
        startPage();
        List<ContaxxYuhui> list = contaxxYuhuiService.selectContaxxYuhuiList(contaxxYuhui);
        return getDataTable(list);
    }

    /**
     * 导出誉辉陶瓷列表
     */
    @RequiresPermissions("system:yuhui:export")
    @Log(title = "誉辉陶瓷", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ContaxxYuhui contaxxYuhui)
    {
        List<ContaxxYuhui> list = contaxxYuhuiService.selectContaxxYuhuiList(contaxxYuhui);
        ExcelUtil<ContaxxYuhui> util = new ExcelUtil<ContaxxYuhui>(ContaxxYuhui.class);
        return util.exportExcel(list, "誉辉陶瓷数据");
    }

    /**
     * 新增誉辉陶瓷
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存誉辉陶瓷
     */
    @RequiresPermissions("system:yuhui:add")
    @Log(title = "誉辉陶瓷", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ContaxxYuhui contaxxYuhui)
    {
        return toAjax(contaxxYuhuiService.insertContaxxYuhui(contaxxYuhui));
    }

    /**
     * 修改誉辉陶瓷
     */
    @RequiresPermissions("system:yuhui:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ContaxxYuhui contaxxYuhui = contaxxYuhuiService.selectContaxxYuhuiById(id);
        mmap.put("contaxxYuhui", contaxxYuhui);
        return prefix + "/edit";
    }

    /**
     * 修改保存誉辉陶瓷
     */
    @RequiresPermissions("system:yuhui:edit")
    @Log(title = "誉辉陶瓷", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ContaxxYuhui contaxxYuhui)
    {
        return toAjax(contaxxYuhuiService.updateContaxxYuhui(contaxxYuhui));
    }

    /**
     * 删除誉辉陶瓷
     */
    @RequiresPermissions("system:yuhui:remove")
    @Log(title = "誉辉陶瓷", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(contaxxYuhuiService.deleteContaxxYuhuiByIds(ids));
    }
}
